/*
作用：声明该接口属于 com.example.mapper 包
规范：通常项目中 mapper 包存放所有数据库操作接口
*/
package com.example.mapper;

/*
动态数据源注解
功能：来自 dynamic-datasource 框架
用途：实现多数据源切换（如操作不同的数据库）
动态数据源支持，通过 @DS 轻松实现读写分离或多租户数据隔离
*/
import com.baomidou.dynamic.datasource.annotation.DS;

/*实体类导入，作用：引入对应的POJO实体类，用于参数和返回值类型*/
/*类型安全：方法参数和返回值有明确的类型约束（如 standardWorkSupervisePojo*/
import com.example.pojo.standardWorkSupervisePojo;

/*定义插入操作的SQL注解，解耦数据库操作，SQL与Java代码分离，便于维护*/
import org.apache.ibatis.annotations.Insert;

/*标识这是MyBatis的Mapper接口，会被Spring扫描到*/
import org.apache.ibatis.annotations.Mapper;

/*定义查询操作的SQL注解*/
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;



/*以下代码为MyBatis Mapper 接口，定义了数据库操作的方法*/



/*引入Java的List集合类，用于返回多条查询结果*/
import java.util.List;



/*
标识这是一个MyBatis的Mapper接口，Spring Boot启动时会自动为其生成代理实现类。
将Java接口与SQL操作绑定，无需手动编写实现类。
*/
@Mapper
public interface standardWorkSuperviseMapp {

    /*
    指定数据源（来自dynamic-datasource框架），
    表示操作newMscLowCodeTest数据库
    */
    @DS("newMscLowCodeTest")

    /*
    MyBatis注解，定义插入SQL语句，
    向表ddm_standard_work_supervise中插入一条记录，包含create_time和update_time字段。
    */
    @Insert("insert into ddm_standard_work_supervise (" +
            "create_time," +
            "update_time," +
            "creator," +
            "process_status," +
            "sys_update_user," +
            "sys_audit_user," +
            "sys_audit_time," +
            "sys_deleted," +
            "project," +
            "`require`," +
            "op," +
            "workshop," +
            "line," +
            "editor," +
            "establishTime," +
            "require_english," +
            "require_russian," +
            "project_english," +
            "project_russian," +
            "id)" +
            " values " +
            "(#{create_time}," +/*MyBatis参数占位符，自动从pojo对象的create_time属性获取值*/
            "#{update_time}," +
            "#{creator}," +
            "#{process_status}," +
            "#{sys_update_user}," +
            "#{sys_audit_user}," +
            "#{sys_audit_time}," +
            "#{sys_deleted}," +
            "#{project}," +
            "#{require}," +
            "#{op}," +
            "#{workshop}," +
            "#{line}," +
            "#{editor}," +
            "#{establishTime}," +
            "#{require_english}," +
            "#{require_russian}," +
            "#{project_english}," +
            "#{project_russian}," +
            "#{id})")
    void insertOne(standardWorkSupervisePojo pojo);/*通常插入操作可不返回结果，也可改为int返回受影响行数*/

    @DS("newMscLowCodeTest")
    @Update("update ddm_standard_work_supervise set " +
            "create_time=#{create_time}, " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +  // 这里补上逗号
            "process_status=#{process_status}, " +  // 这里补上逗号
            "sys_update_user=#{sys_update_user}, " +
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "project=#{project}, " +
            "`require`=#{require}, " +
            "op=#{op}, " +
            "workshop=#{workshop}, " +
            "line=#{line}, " +
            "editor=#{editor}, " +
            "establishTime=#{establishTime}, " +
            "require_english=#{require_english}, " +
            "require_russian=#{require_russian}, " +
            "project_english=#{project_english}, " +
            "project_russian=#{project_russian} " +  // 最后一个可以不加逗号
            "where id=#{id} ")// 通常更新操作需要 WHERE 条件，否则会更新所有行！
    void editOneById(standardWorkSupervisePojo pojo);

    //查询所有的监察记录
    @DS("newMscLowCodeTest")

/*
    MyBatis注解，定义查询SQL
    逻辑删除条件（0表示未删除）
    查询表中所有未被逻辑删除（sys_deleted=0）的记录，返回实体类列表
    MyBatis会自动将查询结果的列名与实体类属性名匹配（需保持一致或通过注解映射）
*/
    @Select("select * from ddm_standard_work_supervise where sys_deleted=0")

    /*将查询结果自动映射为standardWorkSupervisePojo对象的集合*/
    List<standardWorkSupervisePojo> inquiryAll();
}
